<html>
<head><meta charset="utf-8"><title>Endless loading · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html">Endless loading</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="228038914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Endless%20loading/near/228038914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Casper R. Storm <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html#228038914">(Feb 27 2021 at 06:51)</a>:</h4>
<p>Hi everyone,<br>
I am a little sure if this is the right place, but feel free to remove the stream if not.<br>
I am the creator of <a href="https://github.com/ajour/ajour">Ajour</a> - a rather big Rust desktop application. I've been using <code>rust_analyzer</code> in nvim since i started the project and never had any issues. However, lately a few collaborators told me that Ajour didn't work properly with <code>rust_analyzer</code> and VSCode and sure enough when I try to edit eg: <a href="https://github.com/ajour/ajour/blob/master/src/gui/update.rs">gui/update.rs</a> in VSCode it just loads endlessly and never saves the file. That same file works just fine in nvm with rust_analyzer lsp. I am unsure if this is a issue with VSCode, with RA or with Ajour.</p>



<a name="228039166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Endless%20loading/near/228039166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html#228039166">(Feb 27 2021 at 06:55)</a>:</h4>
<p>I can confirm. Looks like we balk on <code>gui::update::query_and_sort_catalog</code></p>



<a name="228039581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Endless%20loading/near/228039581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html#228039581">(Feb 27 2021 at 07:04)</a>:</h4>
<p>As a workaround, you can give an explicit type to the <code>collect</code> call of <code>catalog_rows_and_score</code> (<code>.collect::&lt;Vec&lt;(CatalogRow, i64)&gt;&gt;();</code>)</p>



<a name="228039597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Endless%20loading/near/228039597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html#228039597">(Feb 27 2021 at 07:04)</a>:</h4>
<p>That seems to do the trick, at least in a slightly minimized version of the code</p>



<a name="228041335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Endless%20loading/near/228041335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html#228041335">(Feb 27 2021 at 07:43)</a>:</h4>
<p>Partial minimization:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">query_and_sort_catalog</span><span class="p">(</span><span class="n">ajour</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="n">Ajour</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="n">catalog</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="n">ajour</span><span class="p">.</span><span class="n">catalog</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">query</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ajour</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">catalog_search_state</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">query</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">as_ref</span><span class="p">()</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">map</span><span class="p">(</span><span class="o">|</span><span class="n">s</span><span class="o">|</span><span class="w"> </span><span class="n">s</span><span class="p">.</span><span class="n">to_lowercase</span><span class="p">());</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">flavor</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="n">ajour</span><span class="p">.</span><span class="n">config</span><span class="p">.</span><span class="n">wow</span><span class="p">.</span><span class="n">flavor</span><span class="p">;</span><span class="w"></span>

<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">catalog_rows_and_score</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">catalog</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">addons</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">iter</span><span class="p">()</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">filter_map</span><span class="p">(</span><span class="o">|</span><span class="n">a</span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="nb">Some</span><span class="p">((</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">))</span><span class="w"></span>
<span class="w">            </span><span class="p">})</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">filter</span><span class="p">(</span><span class="o">|</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="n">a</span><span class="p">.</span><span class="n">game_versions</span><span class="w"></span>
<span class="w">                    </span><span class="p">.</span><span class="n">iter</span><span class="p">()</span><span class="w"></span>
<span class="w">                    </span><span class="p">.</span><span class="n">any</span><span class="p">(</span><span class="o">|</span><span class="n">gc</span><span class="o">|</span><span class="w"> </span><span class="n">gc</span><span class="p">.</span><span class="n">flavor</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">flavor</span><span class="p">.</span><span class="n">base_flavor</span><span class="p">())</span><span class="w"></span>
<span class="w">            </span><span class="p">})</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">map</span><span class="p">(</span><span class="o">|</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">score</span><span class="p">)</span><span class="o">|</span><span class="w"> </span><span class="p">(</span><span class="n">CatalogRow</span>::<span class="n">from</span><span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">clone</span><span class="p">()),</span><span class="w"> </span><span class="n">score</span><span class="p">))</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">collect</span>::<span class="o">&lt;</span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">_</span><span class="o">&gt;&gt;</span><span class="p">();</span><span class="w"></span>

<span class="w">        </span><span class="n">catalog_rows_and_score</span><span class="p">.</span><span class="n">sort_by</span><span class="p">(</span><span class="o">|</span><span class="p">(</span><span class="n">addon_a</span><span class="p">,</span><span class="w"> </span><span class="n">score_a</span><span class="p">),</span><span class="w"> </span><span class="p">(</span><span class="n">addon_b</span><span class="p">,</span><span class="w"> </span><span class="n">score_b</span><span class="p">)</span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">score_a</span><span class="p">.</span><span class="n">cmp</span><span class="p">(</span><span class="o">&amp;</span><span class="n">score_b</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">});</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="228042587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Endless%20loading/near/228042587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html#228042587">(Feb 27 2021 at 08:10)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/issues/7796">https://github.com/rust-analyzer/rust-analyzer/issues/7796</a></p>



<a name="228043470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Endless%20loading/near/228043470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html#228043470">(Feb 27 2021 at 08:28)</a>:</h4>
<p>Looks like that's on the RA side of solving:</p>
<div class="codehilite"><pre><span></span><code>[DEBUG hir_ty::traits] solve(UCanonical { canonical: Canonical { value: InEnvironment { environment: Env([]), goal: Implemented({closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;&#39;static 2&lt;[?0 := ^1.0, ?1 := (&amp;&#39;static ^1.1)]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ^1.2, ?1 := ^1.1]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt;: FnMut&lt;2&lt;[?0 := (&amp;&#39;static 2&lt;[?0 := ^0.3, ?1 := ^0.4]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ^0.3, ?1 := ^0.4]&gt;)]&gt;&gt;) }, binders: [U0 with kind type, U0 with kind type, U0 with kind type, U0 with kind type, U0 with kind type] }, universes: 1 }) =&gt; None
[INFO hir_ty::traits] trait_solve_query(Normalize(&lt;|&amp;(?0.0, &amp;?0.1), &amp;(?0.2, ?0.1)| -&gt; Ordering as FnOnce&lt;(&amp;(?0.3, ?0.4), &amp;(?0.3, ?0.4))&gt;&gt;::Output =&gt; Ordering))
[DEBUG hir_ty::traits] solve goal: UCanonical { canonical: Canonical { value: InEnvironment { environment: Env([]), goal: AliasEq(AliasTy(?) = AdtId(EnumId(EnumId(8)))&lt;[]&gt;) }, binders: [U0 with kind type, U0 with kind type, U0 with kind type, U0 with kind type, U0 with kind type] }, universes: 1 }
[DEBUG hir_ty::traits::chalk] impls_for_trait FnOnce
[DEBUG hir_ty::traits::chalk] impls_for_trait returned 0 impls
[DEBUG hir_ty::traits::chalk] impls_for_trait FnOnce
[DEBUG hir_ty::traits::chalk] impls_for_trait returned 0 impls
[DEBUG hir_ty::traits::chalk] impls_for_trait FnOnce
[DEBUG hir_ty::traits::chalk] impls_for_trait returned 0 impls
[DEBUG hir_ty::traits::chalk] impls_for_trait FnOnce
...
</code></pre></div>



<a name="228043479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Endless%20loading/near/228043479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Casper R. Storm <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html#228043479">(Feb 27 2021 at 08:28)</a>:</h4>
<p>Thanks for investigating and digging into the issue, <span class="user-mention" data-user-id="203546">@Laurențiu Nicola</span> &amp; <span class="user-mention" data-user-id="125131">@detrumi</span>.<br>
Let me know if I can do anything to help out.</p>



<a name="228043507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Endless%20loading/near/228043507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html#228043507">(Feb 27 2021 at 08:29)</a>:</h4>
<p>I recall our handling of closures being less not quite great</p>



<a name="228043577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Endless%20loading/near/228043577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html#228043577">(Feb 27 2021 at 08:30)</a>:</h4>
<p><span class="user-mention" data-user-id="392693">@Casper R. Storm</span> We're able to reproduce it with a small example, so that should be enough for us to figure out the problem and fix it <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="228043625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Endless%20loading/near/228043625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html#228043625">(Feb 27 2021 at 08:31)</a>:</h4>
<p><span class="user-mention" data-user-id="203546">@Laurențiu Nicola</span> Yeah, it's very hard to figure out what's going on when closures are involved</p>



<a name="228043735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Endless%20loading/near/228043735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html#228043735">(Feb 27 2021 at 08:33)</a>:</h4>
<p><span class="user-mention" data-user-id="392693">@Casper R. Storm</span> in the meanwhile, you can use that workaround I mentioned to make it easier on the users. I checked and analysis completes after that change</p>



<a name="228043814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Endless%20loading/near/228043814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html#228043814">(Feb 27 2021 at 08:34)</a>:</h4>
<div class="codehilite" data-code-language="Diff"><pre><span></span><code><span class="gh">diff --git i/src/gui/update.rs w/src/gui/update.rs</span>
<span class="gh">index 9c47a6e..b54b25a 100644</span>
<span class="gd">--- i/src/gui/update.rs</span>
<span class="gi">+++ w/src/gui/update.rs</span>
<span class="gu">@@ -2534,7 +2534,7 @@ fn query_and_sort_catalog(ajour: &amp;mut Ajour) {</span>
                 CatalogCategory::Choice(name) =&gt; a.categories.iter().any(|c| c == name),
             })
             .map(|(a, score)| (CatalogRow::from(a.clone()), score))
<span class="gd">-            .collect::&lt;Vec&lt;_&gt;&gt;();</span>
<span class="gi">+            .collect::&lt;Vec&lt;(CatalogRow, i64)&gt;&gt;();</span>

         let mut catalog_rows = if query.is_some() {
             // If a query is defined, the default sort is the fuzzy match score
</code></pre></div>



<a name="228043829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Endless%20loading/near/228043829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html#228043829">(Feb 27 2021 at 08:35)</a>:</h4>
<p>You probably didn't run into it in <code>nvim</code> because the Code extension does things like semantic highlighting and type hints, which need trait solving</p>



<a name="228045268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Endless%20loading/near/228045268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Endless.20loading.html#228045268">(Feb 27 2021 at 09:05)</a>:</h4>
<p>Filed <a href="https://github.com/rust-lang/chalk/issues/688">chalk#688</a> with a description of the endlessly expanding query (it keeps nesting lifetimes)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>